package cn.rengy.web.framework.shiro.token;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.shiro.authc.HostAuthenticationToken;

public abstract class AbstractAuthenticationToken implements HostAuthenticationToken {

	private static final long serialVersionUID = 1L;

	private String userAgent;
	
	private String clientIp;

	public AbstractAuthenticationToken() {
	}
	
	public AbstractAuthenticationToken(String userAgent, String clientIp) {
		this.userAgent = userAgent;
		this.clientIp = clientIp;
	}

	public String getUserAgent() {
		return userAgent;
	}

	public void setUserAgent(String userAgent) {
		this.userAgent = userAgent;
	}

	public String getClientIp() {
		return clientIp;
	}

	public void setClientIp(String clientIp) {
		this.clientIp = clientIp;
	}
	
	public String getHost() {
		return clientIp;
	}
	
	public String getClientId() {
		return DigestUtils.md5Hex(userAgent+clientIp);
	}
}
